<?php
namespace app\usercp\controller;

use app\usercp\exception\UsercpException;
use think\Request;

class Upload extends Usercp
{
    //编辑器图片上传
    public function upload_editor()
    {
        $uploadModel = new \app\common\service\Upload\Service('file');
        if ($uploadModel->upload()) {
            return $this->result(['src'=>$uploadModel->fileName],0,'上传成功');
        }
        return $this->result('',-1,$uploadModel->error);
    }

    //图片上传
    public function upload(Request $request)
    {
        $uploadModel = new \app\common\service\Upload\Service('file');
        if ($uploadModel->upload()) {
            return $this->result($uploadModel->fileName,200,'上传成功');
        }
        return $this->result('',0,$uploadModel->error);
    }
}